// utils/mysql/sequelize-auto/auto.js
import SequelizeAuto from 'sequelize-auto'
import dataBase from '../config'
const {
  host,
  user,
  password,
  database,
  dialect,
  port
} = dataBase.dataBase

const options = {
  host,
  dialect,
  directory: 'models', // 指定输出 models 文件的目录
  port,
  additional: {
    timestamps: false
  }
}

const auto = new SequelizeAuto(database, user, password, options)

auto.run().then(data => {
  // console.log(data.tables);      // table and field list
  // console.log(data.foreignKeys); // table foreign key list
  // console.log(data.indexes);     // table indexes
  // console.log(data.hasTriggerTables); // tables that have triggers
  // console.log(data.relations);   // relationships between models
  // console.log(data.text)         // text of generated models
}).catch(err => {
  if (err) throw err
})